/* $Id: ModelsFactory.java 137 2011-08-29 20:33:36Z altdotua@gmail.com $ */

package alt.djudge.frontend.server.models;

import org.apache.log4j.Logger;

import alt.djudge.frontend.server.datatypes.AbstractEntry;
import alt.djudge.frontend.server.datatypes.ContestEntry;
import alt.djudge.frontend.server.datatypes.ContestLanguageEntry;
import alt.djudge.frontend.server.datatypes.ContestProblemEntry;
import alt.djudge.frontend.server.datatypes.ContestUserEntry;
import alt.djudge.frontend.server.datatypes.LanguageEntry;
import alt.djudge.frontend.server.datatypes.LocaleEntry;
import alt.djudge.frontend.server.datatypes.ProblemEntry;
import alt.djudge.frontend.server.datatypes.ProblemStatementEntry;
import alt.djudge.frontend.server.datatypes.SessionEntry;
import alt.djudge.frontend.server.datatypes.SubmissionEntry;
import alt.djudge.frontend.server.datatypes.UserEntry;
import alt.djudge.frontend.shared.dto.admin.ContestEntryDTO;
import alt.djudge.frontend.shared.dto.admin.ContestLanguageEntryDTO;
import alt.djudge.frontend.shared.dto.admin.ContestProblemEntryDTO;
import alt.djudge.frontend.shared.dto.admin.ContestUserEntryDTO;
import alt.djudge.frontend.shared.dto.admin.AdminDTOEntry;
import alt.djudge.frontend.shared.dto.admin.LanguageEntryDTO;
import alt.djudge.frontend.shared.dto.admin.LocaleEntryDTO;
import alt.djudge.frontend.shared.dto.admin.ProblemEntryDTO;
import alt.djudge.frontend.shared.dto.admin.ProblemStatementEntryDTO;
import alt.djudge.frontend.shared.dto.admin.SessionEntryDTO;
import alt.djudge.frontend.shared.dto.admin.SubmissionEntryDTO;
import alt.djudge.frontend.shared.dto.admin.UserEntryDTO;


public class ModelsFactory
{
	private final static Logger log = Logger.getLogger(ModelsFactory.class);
	
	public static CoreInterface<? extends AbstractEntry> getModelForEntryClass(
			Class<? extends AbstractEntry> clazz)
	{
		if (clazz.equals(ContestEntry.class))
			return ContestsModel.getCore();
		if (clazz.equals(ContestLanguageEntry.class))
			return ContestLanguagesModel.getCore();
		if (clazz.equals(ContestProblemEntry.class))
			return ContestProblemsModel.getCore();
		if (clazz.equals(ContestUserEntry.class))
			return ContestUsersModel.getCore();
		if (clazz.equals(LanguageEntry.class))
			return LanguagesModel.getCore();
		if (clazz.equals(LocaleEntry.class))
			return LocalesModel.getCore();
		if (clazz.equals(ProblemEntry.class))
			return ProblemsModel.getCore();
		if (clazz.equals(ProblemStatementEntry.class))
			return ProblemStatementsModel.getCore();
		if (clazz.equals(SessionEntry.class))
			return SessionsModel.getCore();
		if (clazz.equals(SubmissionEntry.class))
			return SubmissionsModel.getCore();
		if (clazz.equals(UserEntry.class))
			return UsersModel.getCore();
		log.trace("No model for class " + clazz);
		return null;
	}

	public static CoreInterface<? extends AbstractEntry> getModelForDTOClass(
			Class<? extends AdminDTOEntry> clazz)
	{
		if (clazz.equals(ContestEntryDTO.class))
			return ContestsModel.getCore();
		if (clazz.equals(ContestLanguageEntryDTO.class))
			return ContestLanguagesModel.getCore();
		if (clazz.equals(ContestProblemEntryDTO.class))
			return ContestProblemsModel.getCore();
		if (clazz.equals(ContestUserEntryDTO.class))
			return ContestUsersModel.getCore();
		if (clazz.equals(LanguageEntryDTO.class))
			return LanguagesModel.getCore();
		if (clazz.equals(LocaleEntryDTO.class))
			return LocalesModel.getCore();
		if (clazz.equals(ProblemEntryDTO.class))
			return ProblemsModel.getCore();
		if (clazz.equals(ProblemStatementEntryDTO.class))
			return ProblemStatementsModel.getCore();
		if (clazz.equals(SessionEntryDTO.class))
			return SessionsModel.getCore();
		if (clazz.equals(SubmissionEntryDTO.class))
			return SubmissionsModel.getCore();
		if (clazz.equals(UserEntryDTO.class))
			return UsersModel.getCore();
		log.trace("No model for class " + clazz);
		return null;
	}
}
